/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.kimstore.gui.sales;

import com.kimstore.bean.Item;
import com.kimstore.factory.DaoFactory;
import java.util.ArrayList;

/**
 *
 * @author Administrator
 */
public class AddFreebieToItemController {
    
    private AddItemToOrderController parentController;
    private AddFreebieToItemWindow window;
    
    public AddFreebieToItemController(AddItemToOrderController parentController){
        this.parentController = parentController;
    }
    
    public void displayWindow(){
        ArrayList<Item> items = (ArrayList<Item>) DaoFactory.getInstance().getItemDao().getAllAvailableItems();
        
        if(parentController.getAllSelectedItems() != null)
            items.removeAll(parentController.getAllSelectedItems());

        window = new AddFreebieToItemWindow(this);
        window.populateItemsTable(items);
        window.showWindow();
    }
    
    public void fromWindow(String sku){
        parentController.createAddFreebieToItemControllerCallback(sku);
    }
    
}
